package de.gameduell.framework.asset {
	import flash.net.URLLoader;
	import flash.net.URLRequest;	

	/**
	 * @author GD
	 */
	public class TextAsset extends Asset {
			
		private var _loader:URLLoader;

		public function TextAsset(aId:String, aUrl:String) {
			super(aId, aUrl);
			_type  = AssetTypes.TEXT;
			_loader = new URLLoader();
			registerLoader(_loader);		
		}
		
		override public function load():void{
			_loader.load(new URLRequest(url));
		}

		override public function get percentLoaded():int{
			return Math.round((_loader.bytesLoaded/_loader.bytesTotal)*100);
		}

		override public function get data():Object{
			return _loader.data;
		}
		
		public function get text():String{
			return String(data);
		}
	}
}
